﻿using DataAccess.Entity;
using DataAccess.Mapping;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccess
{
    public class MysqlContext : DbContext
    {
        /// <summary>
        /// 数据库默认 Scheme 
        /// </summary>
        public static string Schema
        {
            get
            {
                return new MySqlConnection(ConfigurationManager.AppSettings["DbConStr"]).Database;
            }
        }

        public MysqlContext() : base(new MySqlConnection(ConfigurationManager.AppSettings["DbConStr"]), true)
        {
        }

        public DbSet<First> Firsts { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new FirstMap());

            base.OnModelCreating(modelBuilder);
        }

    }
}
